# Maintainer: Orhun Parmaksız <orhun@archlinux.org>
# Contributor: Quentin Bouvet <qbouvet at outlook dot com>

pkgname=bash-preexec
pkgver=0.5.0
pkgrel=1
pkgdesc="preexec and precmd functions for Bash just like Zsh"
arch=('any')
url="https://github.com/rcaloras/bash-preexec"
license=('MIT')
makedepends=('bash-bats')
source=("$pkgname-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz"
        "$pkgname-$pkgver-tests.patch::$url/commit/a44754f5c3ca76b0330324680670cb8574d2768f.patch")
install=$pkgname.install
sha256sums=('23c589cd1da209c0598f92fac8d81bb11632ba1b2e68ccaf4ad2c4f3204b877c'
            'db9e914aa8cb27883c9ba100ff8b38080f9108fd6f438764b9ae1ca4ae2d17bf')

prepare() {
  cd "$pkgname-$pkgver"
  patch -Np1 -i "../$pkgname-$pkgver-tests.patch"
}

check() {
  cd "$pkgname-$pkgver/test"
  bats .
}

package() {
  cd "$pkgname-$pkgver"
  install -Dm 755 "${pkgname}.sh" -t "$pkgdir/usr/share/$pkgname" 
  install -Dm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname"
  install -Dm 644 LICENSE.md -t "$pkgdir/usr/share/licenses/$pkgname"
}

# vim:set ts=2 sw=2 et:
